package gui;

import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

import javax.swing.UIManager;

import system.Client;

/**
 * A class the runs the GeoExplorer application as a whole.
 * @author Jacob Freemyer
 *
 */
public class Application extends JFrame
{
	/**
	 * Serialized
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The client used to connect with Server
	 */
	private static Client client;
	
	/**
	 * Main method to start the application
	 * @param args
	 * 	Standard input
	 * @throws Exception
	 * 		An exception if something goes wrong
	 */
	public static void main(String[] args) throws Exception
	{
		try
		{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch(Exception e)
		{
			// Do nothing (i.e. let Java choose the look and feel)
		}
		Application app = new Application();
		app.setSize(new Dimension(630, 600));
		app.setDefaultCloseOperation(EXIT_ON_CLOSE);
		new LoginWindow(app);
		
		
	}
	
	/**
	 * An Application instance that is used to initialize the program
	 * @throws Exception
	 * 		Exception if a problem makes it to Application
	 */
	public Application() throws Exception
	{
		client = new Client();
		this.setTitle("GeoExplorer");
		this.setIconImage(new ImageIcon("resources/images/world.jpg").getImage());
	}
	
	
	/**
	 * Getter for getting the Client of the application
	 * @return
	 * 		Applications Client instance
	 */
	public Client getClient()
	{
		return client;
	}
	
	/**
	 * Allows to reset the Client of the Application
	 * @throws Exception
	 * 		Exception if a problem makes it to Application
	 */
	public void resetClient() throws Exception
	{
		client = new Client();
	}
}
